package com.ruoyi.common.utils;

import cn.hutool.core.util.IdcardUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidatePhoneNumber {
    /**
     * 正则表达式校验手机号码
     *
     * @return false 则手机号码不合法，true 则手机号码校验通过
     */
    public static boolean validatePhoneNumber(String phoneNumber) {
        if (phoneNumber.length() != 11) {
            return false;
        }
        String regPattern = "^1[2|3|4|5|6|7|8|9]\\d{9}$";
        Pattern pattern = Pattern.compile(regPattern);
        Matcher matcher = pattern.matcher(phoneNumber);
        boolean isMatch = matcher.matches();
        return isMatch;
    }
}
